﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using NetCMS.Content;
using NetCMS.Content.Common;

public partial class manage_news_class_site : NetCMS.Web.UI.ManagePage
{
    UserMisc rd = new UserMisc();
    Channel md = new Channel();
    public string ClassList = string.Empty;
    public string IsSuper = string.Empty;
    public bool LookAll = false;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Response.CacheControl = "no-cache";
            Response.Expires = 0;

            //shortcut_id.InnerHtml = ShortcutList();
            returnmenu.InnerHtml = rmenu();
            string listchmenu = string.Empty;
            IDataReader drs1 = md.getModelTemplet(0);
            
            this.Authority_Code = "C067";
            LookAll = CheckAuthority();//判断是否有查看所有新闻的权限

            #region 读取会员拥有权限的栏目
            NetCMS.Content.AdminGroup agc = new NetCMS.Content.AdminGroup();
            IsSuper = agc.GetAdminIsSuper(this.UserNum);

            if (IsSuper != "1")//判断是不是超级管理员
            {
                string adminGroupNumber = agc.getAdminGroup(this.UserNum);
                IDataReader rdg = agc.getAdminGroups(adminGroupNumber);
                while (rdg.Read())
                {
                    if (!rdg.IsDBNull(0))
                    {
                        ClassList = rdg.GetString(0);
                    }
                }
                rdg.Close();
            }
            #endregion

            while (drs1.Read())
            {
                if (IsSuper == "1")
                {
                    listchmenu += "<li style=\"list-style:none;\"><img src='../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/admin/menu_dot_21.gif' alt='' border='0'><a class=\"menu_ctr\" href=\"../channel/read.aspx?ChID=" + drs1["ID"].ToString() + "\" target=\"menu\">" + drs1["channelName"].ToString() + "</a></li>\r";
                }
                else
                {
                    if (ClassList.IndexOf(drs1["ID"].ToString()) >= 0)
                    {
                        listchmenu += "<li style=\"list-style:none;\"><img src='../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/admin/menu_dot_21.gif' alt='' border='0'><a class=\"menu_ctr\" href=\"../channel/read.aspx?ChID=" + drs1["ID"].ToString() + "\" target=\"menu\">" + drs1["channelName"].ToString() + "</a></li>\r";
                    }
                }
            }
            drs1.Close();
            channelDivMenu.InnerHtml = GetModelMenu(0, 0);
        }
    }

    protected string GetModelMenu(int ParentID, int Layer)
    {
        string listchmenu = string.Empty;
        IDataReader drs = md.getModelTemplet(ParentID);
        while (drs.Read())
        {
            string stxt = "";
            if (Layer > 0)
            {
                stxt = "┞┄ ";
            }
            //if (drs["hashCount"].ToString() != "0")
            //{
            //    listchmenu += "<li style=\"list-style:none;\">" + stxt + "<img src='../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/admin/menu_dot_21.gif' alt='' border='0'>" + drs["channelName"].ToString() + "</li>\r";
            //}
            //else
            //{

            if (IsSuper == "1")
            {
                listchmenu += "<li style=\"list-style:none;\">" + stxt + "<img src='../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/admin/menu_dot_21.gif' alt='' border='0'><a class=\"menu_ctr\" href=\"../channel/read.aspx?ChID=" + drs["ID"].ToString() + "\" target=\"menu\">" + drs["channelName"].ToString() + "</a></li>\r";
            }
            else
            {
                if (ClassList.IndexOf(drs["ID"].ToString()) >= 0)
                {
                    listchmenu += "<li style=\"list-style:none;\">" + stxt + "<img src='../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/admin/menu_dot_21.gif' alt='' border='0'><a class=\"menu_ctr\" href=\"../channel/read.aspx?ChID=" + drs["ID"].ToString() + "\" target=\"menu\">" + drs["channelName"].ToString() + "</a></li>\r";
                }
            }
            //}
            listchmenu += GetModelMenu(int.Parse(drs["ID"].ToString()), (Layer + 1));
        }
        drs.Close();
        return listchmenu;
    }


    /// <summary>
    /// 获得返回菜单路径
    /// </summary>
    /// <returns></returns>
    protected string rmenu()
    {
        string liststr = "";
        liststr += "&nbsp;&nbsp;<a href=\"../menu.aspx?Type=0\" title=\"返回上一级菜单\"><font color=\"red\">返回</font></a>";
        return liststr;
    }

    /// <summary>
    /// 显示快捷菜单
    /// </summary>
    /// <returns></returns>

    protected string ShortcutList()//显示快捷菜单
    {
        IDataReader dr = rd.ShortcutList(UserNum, 1);
        string qflg = "\r<div>\r";
        int i = 0;
        while (dr.Read())
        {
            string QMID = dr["QMID"].ToString();
            string qName = dr["qName"].ToString();
            string FilePath = dr["FilePath"].ToString();
            qflg = qflg + " <li onmouseover=\"javascript:setshorcutmenu('none');\" style=\"list-style:none;padding-left:5px;\"><img src='../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/admin/menu_dot_21.gif' alt=\"\" border=\"0\">";
            qflg = qflg + "<a class=\"menulist\" href=\"../" + FilePath + "\" target=\"sys_main\">" + qName + "</a></li>";
            i++;
        }
        dr.Close();
        if (i < 1)
        {
            qflg = qflg + "<li style=\"list-style:none;padding-left:5px;\">无快捷方式，<a href=\"sys/shortcut_list.aspx\" target=\"sys_main\"><font color=\"red\">创建</font></a></li>";
        }
        qflg = qflg + "</div>\r";
        return qflg;
    }
}
